#include "stdafx.h"

#include "common.h"

template<typename T>
void setBit(T& d, int pos);

template<typename T>
void clearBit(T& d, int pos);

void testOperators()
{
	int a = 10;
	int b = 20;
	a *= b + 1;//a *= (b + 1)
	printf("%d %d\n", a, b);

	a = 3;
	b = ++a;
	printf("%d %d\n", a, b);
	a = 3;
	b = a++;
	printf("%d %d\n", a, b);

	a = (b = 3, b + 2);
	printf("%d %d\n", a, b);

	float f = 3.14f;
	int i = (int)f;
	int j = int(f);
	printf("%d %d\n", i,j);

	int k = 500;
	setBit(k, 16);
	printAsRAMBinary2(k);

	int k2 = 500;
	clearBit(k2, 6);
	printAsRAMBinary2(k2);
}

template<typename T>
void setBit(T& d, int pos)
{
	if (pos < 0 || pos >= sizeof(T) * 8) return;

	d |= (0x1<<pos);
}

template<typename T>
void clearBit(T& d, int pos)
{
	if (pos < 0 || pos >= sizeof(T) * 8) return;

	d &= ~(0x1 << pos);
}